import * as constants from './constants';
import { fromJS } from 'immutable';

const defaultState = fromJS({
    focused: false,
    list: [],
    page: 1,
    totalPage: 1,
    mouseIn: false
 })
 
 export default (state = defaultState, action) => {
    switch(action.type) {
        case constants.INPUT_CHANGE_FOCUS:
            return state.set('focused', true);
        case constants.INPUT_CHANGE_BLUR:
            return state.set('focused', false);
        case constants.CHANGE_LIST:
            return state.merge({
                list: action.data,
                totalPage: action.totalPage
            })
        case constants.ON_MOUSE_ENTER:
            return state.set('mouseIn', true);
        case constants.ON_MOUSE_LEAVE:
            return state.set('mouseIn', false);
        case constants.GET_CHANGE_LIST:
            return state.set('page', action.page);    
        default:
            return state;       
    }
 }